clc;
clear all;
close all;

% %polynomial=[1 0 1 1 1 0 0 0 ];
% 
% %p=zeros(100,1);
% %state=[1 1 1 1 1 1 1 1];
% 
% 
% %for index=1:100
% %    p(index)  = state(1);
%     feedback  = mod(sum(polynomial.*state),2);
%     state     = circshift(state',-1)';
%     state(8)  = feedback; 
% end
% 
% preamble = 1 - 2*p;
preamble = preamble_gen(100);
load('lenawithpreamble.mat');
r_data = awgn(final,10);
index = preamble_search(r_data,15,preamble);
rcveddata = r_data(index:end);
output_image = demapper(rcveddata,512,512);
